package com.ruoyi.web.controller.hedianzhan;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.system.domain.SQuestions;
import com.ruoyi.system.service.ISQuestionsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2021-10-29
 */
@Controller
@RequestMapping("/system/questions")
public class SQuestionsController extends BaseController
{
    private String prefix = "system/questions";

    @Autowired
    private ISQuestionsService sQuestionsService;

    @RequiresPermissions("system:questions:view")
    @GetMapping()
    public String questions()
    {
        return prefix + "/questions";
    }

    /**
     * 查询【分页】列表
     */
//    @RequiresPermissions("system:questions:list")
//    @PostMapping("/list")
    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam("pageNumber")String pageNumber,@RequestParam("lines")String lines,@RequestParam("questionType")String questionType,@RequestParam("add_user")String add_user)
    {
        ;
        startPage();
        List<SQuestions> list = sQuestionsService.selectSQuestionsList(new SQuestions());
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:questions:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SQuestions sQuestions)
    {
        List<SQuestions> list = sQuestionsService.selectSQuestionsList(sQuestions);
        ExcelUtil<SQuestions> util = new ExcelUtil<SQuestions>(SQuestions.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("system:questions:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SQuestions sQuestions)
    {
        return toAjax(sQuestionsService.insertSQuestions(sQuestions));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        SQuestions sQuestions = sQuestionsService.selectSQuestionsById(id);
        mmap.put("sQuestions", sQuestions);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("system:questions:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SQuestions sQuestions)
    {
        return toAjax(sQuestionsService.updateSQuestions(sQuestions));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:questions:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sQuestionsService.deleteSQuestionsByIds(ids));
    }
}
